package day20170506.ch01;

import static org.junit.Assert.*;

import org.junit.Test;

/**
 * 动态代理测试
 * @author 罗智壕-13424431416
 *
 * 2017年5月6日
 */
public class DynaicProxyTest {
	
	/**
	 * 学生增加动态代理测试
	 * @throws Exception
	 */
	@Test
	public void proxyTest() throws Exception {
		StudentDao studentDao = new StudentDaoImpl();
		DynaicProxy proxy = new DynaicProxy(studentDao);
		
		Object object = proxy.newProxyObject();
		StudentDao dao = (StudentDao)object;
		dao.add("123", "123");
		
	}
	
	/**
	 * 老师动态代理测试
	 * @throws Exception
	 */
	@Test
	public void proxyTeacherTest() throws Exception {
		TeacherDao teacherDao = new TeacherDaoImpl();
		DynaicProxy proxy = new DynaicProxy(teacherDao);
		
		Object object = proxy.newProxyObject();
		TeacherDao dao = (TeacherDao)object;
		dao.addTeacher("李四");
	}
}
